import java.util.*;

public class Example {
    public static void main(String args[]) {
        Random r = new Random();
        Scanner in = new Scanner(System.in);
        HashSet<Integer> triedAnss = new HashSet<>();
        while (true) {
            int num1 = r.nextInt(1000);
            int num2 = r.nextInt(1000);
            triedAnss.clear();
            System.out.println(num1 + " + " + num2 + " = ?");
            System.out.print(">");
            int userAns = Integer.valueOf(in.nextLine());
            while (userAns != (num1 + num2)) {
                if (triedAnss.contains(userAns)) {
                    System.out.println("You have already tried " + userAns +
                            ", please try again.");
                }
                else {
                    triedAnss.add(userAns);
                    System.out.println("Not correct, please try again.");
                }
                System.out.print(">");
                userAns = Integer.valueOf(in.nextLine());
            }
            System.out.println("Great! Here comes the next test.");
        }
    }
}
